package com.endurance.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @Author: sunlin
 * @Date: 2024-04-21 3:14
 * @Version: 1.0
 * @Description: 全局过滤器
 */

@Configuration
public class CustomerGlobalFilter implements GlobalFilter, Ordered {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("进入全局filter..");
        return chain.filter(exchange);
    }

    /**
     * 代表filter的执行顺序 默认按照自然排序  0 1 2 3 4 5 代表filter的执行顺序  默认：按照自然排序
     * -1： 在所有的filter之前执行
     *
     * @return
     */
    @Override
    public int getOrder() {
        return 0;
    }

}
